Sets
	
	K  Archs /k1 * k7/
	P  Paths /p1 * p45/
	I  Demands /i1 * i10/
;

PARAMETER aa(k,p) arc path incidence matrix
/
    k1.  p1  1.0
    k2.  p2  1.0
    k3.  p2  1.0
    k2.  p3  1.0
    k4.  p3  1.0
    k5.  p3  1.0
    k2.  p4  1.0
    k4.  p4  1.0
    k7.  p4  1.0
    k6.  p4  1.0
    k1.  p5  1.0
    k6.  p5  1.0
    k1.  p6  1.0
    k3.  p6  1.0
    k4.  p6  1.0
    k7.  p6  1.0
    k1.  p7  1.0
    k5.  p7  1.0
    k7.  p7  1.0
    k2.  p8  1.0
    k4.  p8  1.0
    k7.  p8  1.0
    k2.  p9  1.0
    k3.  p9  1.0
    k6.  p9  1.0
    k2. p10  1.0
    k4. p10  1.0
    k5. p10  1.0
    k6. p10  1.0
    k1. p11  1.0
    k3. p11  1.0
    k4. p11  1.0
    k1. p12  1.0
    k5. p12  1.0
    k1. p13  1.0
    k6. p13  1.0
    k7. p13  1.0
    k2. p14  1.0
    k4. p14  1.0
    k2. p15  1.0
    k3. p15  1.0
    k5. p15  1.0
    k2. p16  1.0
    k3. p16  1.0
    k6. p16  1.0
    k7. p16  1.0
    k2. p17  1.0
    k1. p18  1.0
    k3. p18  1.0
    k1. p19  1.0
    k5. p19  1.0
    k4. p19  1.0
    k1. p20  1.0
    k6. p20  1.0
    k7. p20  1.0
    k4. p20  1.0
    k6. p21  1.0
    k5. p22  1.0
    k7. p22  1.0
    k3. p23  1.0
    k4. p23  1.0
    k7. p23  1.0
    k1. p24  1.0
    k2. p24  1.0
    k4. p24  1.0
    k7. p24  1.0
    k5. p25  1.0
    k6. p26  1.0
    k7. p26  1.0
    k3. p27  1.0
    k4. p27  1.0
    k1. p28  1.0
    k2. p28  1.0
    k4. p28  1.0
    k3. p29  1.0
    k1. p30  1.0
    k2. p30  1.0
    k5. p31  1.0
    k4. p31  1.0
    k6. p32  1.0
    k7. p32  1.0
    k4. p32  1.0
    k7. p33  1.0
    k6. p34  1.0
    k5. p34  1.0
    k6. p35  1.0
    k3. p35  1.0
    k4. p35  1.0
    k6. p36  1.0
    k1. p36  1.0
    k2. p36  1.0
    k4. p36  1.0
    k6. p37  1.0
    k1. p37  1.0
    k2. p37  1.0
    k6. p38  1.0
    k5. p38  1.0
    k4. p38  1.0
    k6. p39  1.0
    k3. p39  1.0
    k7. p40  1.0
    k4. p40  1.0
    k4. p41  1.0
    k7. p42  1.0
    k6. p42  1.0
    k3. p42  1.0
    k7. p43  1.0
    k6. p43  1.0
    k1. p43  1.0
    k2. p43  1.0
    k5. p44  1.0
    k3. p44  1.0
    k5. p45  1.0
    k1. p45  1.0
    k2. p45  1.0
/;

PARAMETER dd(i,p) demand path incidence matrix
/
    i1.  p1  1.0
    i1.  p2  1.0
    i1.  p3  1.0
    i1.  p4  1.0
    i2.  p5  1.0
    i2.  p6  1.0
    i2.  p7  1.0
    i2.  p8  1.0
    i2.  p9  1.0
    i2. p10  1.0
    i3. p11  1.0
    i3. p12  1.0
    i3. p13  1.0
    i3. p14  1.0
    i3. p15  1.0
    i3. p16  1.0
    i4. p17  1.0
    i4. p18  1.0
    i4. p19  1.0
    i4. p20  1.0
    i5. p21  1.0
    i5. p22  1.0
    i5. p23  1.0
    i5. p24  1.0
    i6. p25  1.0
    i6. p26  1.0
    i6. p27  1.0
    i6. p28  1.0
    i7. p29  1.0
    i7. p30  1.0
    i7. p31  1.0
    i7. p32  1.0
    i8. p33  1.0
    i8. p34  1.0
    i8. p35  1.0
    i8. p36  1.0
    i9. p37  1.0
    i9. p38  1.0
    i9. p39  1.0
    i9. p40  1.0
   i10. p41  1.0
   i10. p42  1.0
   i10. p43  1.0
   i10. p44  1.0
   i10. p45  1.0
/;

Parameter T(I)  type of demand
	  /
	  i1 1
	  i2 2
	  i3 2
	  i4 2
	  i5 1
	  i6 1
	  i7 1
	  i8 2
	  i9 2
	  i10 2/;
	   
Parameter D(I);
D(I)$(T(I) = 1) = 2.05;
D(I)$(T(I) = 2) = 1.5;

*Display D;

Parameter uc(k) unit cost on each arch
/
          k1 1.0
	  k2 2.9
	  k3 1.0
	  k4 2.9
	  k5 1.0
	  k6 1.0
	  k7 2.9
/
;


Scalar
	tc   /20.0/
;

Parameter op(k) operation probabilities
/
	k1 0.7
	k2 1
	k3 0.7
	k4 1
	k5 0.7
	k6 0.7
	k7 1
/
;
*all 0.5 above should be 0.7

Variables
	x(k)   installed capacity on arch k
	y(p)   satisfied demand on path p
	u(i)   unsatisfied calls of ith demand
	z      total unsatisfied calls
;

Positive variables
	x,y,u
;

Equations
	cost
	archcap
	archbnd(k)
	demandbal(i)
;

cost ..
	z =e= sum (i, u(i))
;

archcap..
	tc =g= sum(k, uc(k) * x(k))
;
	
archbnd(k) ..
	op(k)*x(k) =g= sum(p, aa(k,p) * y(p))
;

demandbal(i) ..
	u(i) =e= d(i) - sum(p, dd(i,p) * y(p))
;
	
model capex /all/;

solve capex using lp minimizing z;
display D, uc, tc;
display x.L, y.L, u.L;
